package com.hua.demo.edu.controller.front;/*
@Author:张华
@File:teacherfront.java
@Time:2021/12/4 14:48
*/

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hua.R;
import com.hua.demo.edu.entity.Course;
import com.hua.demo.edu.entity.Teacher;
import com.hua.demo.edu.service.CourseService;
import com.hua.demo.edu.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("edu/front/teacher")
public class teacherfront {
    @Autowired
    TeacherService teacherService;
    @Autowired
    CourseService courseService;
    //讲师列表化显示
    @PostMapping("getlist/{page}/{num}")
    public R listteacher(@PathVariable long page,@PathVariable long num ){
        Page<Teacher> teacherPage = new Page<>(page,num);
        Map<String,Object> map=teacherService.gettecherfrontlist(teacherPage);
        return R.ok().data(map);
    }

    @GetMapping("getdetailteacher/{id}")
    public R getteacher(@PathVariable String id){
        Teacher teacher = teacherService.getById(id);
        QueryWrapper<Course> que = new QueryWrapper<>();
        que.eq("teacher_id", id);
        List<Course> list = courseService.list(que);

        return R.ok().data("teacher",teacher).data("list",list);

    }
}
